home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / comm / gold22.zip / GOLD.ASM next >
Assembly Source File  |  1992-02-16  |  18KB  |  593 lines

  1.     PAGE    64,132
  2.     TITLE    GOLD key from NUMLOCK
  3.     NAME    GOLD
  4. ;
  5. ; This program maps the NUM LOCK key (scan code 45H) to F1 (scan code 3BH)
  6. ; for use with Kermit emulating a DEC VT100.
  7. ;
  8. ; Version 2.2 -    February 1992
  9. ;        Added safety checks to installation code
  10. ; Version 2.1 - June 1991
  11. ;        Changed default multiplex ID to 09FH (was 0DCH) to avoid
  12. ;        problems with some versions of the KEYB program.
  13. ; Version 2.0 - March 1991
  14. ;        SHIFT and NUM LOCK acts as normal NUM LOCK
  15. ;        ALT and NUM LOCK inverts current GOLD status
  16. ;        Fix for problem with some clone BIOSes
  17. ;        Fix non-detection of BIOS intercept support
  18. ;        Use INT 09H if interrupt intercept not available
  19. ;
  20. ; Bob Eager
  21. ;    rde@ukc.ac.uk        USENET (preferred over ibmpcug)
  22. ;    rde@ibmpcug.co.uk    USENET
  23. ;    100016,2770        CompuServe
  24. ;    +44 227 367270        Telephone
  25. ;
  26. ; You may distribute this program freely as long as all of the files that
  27. ; make up the package (see the documentation file) are kept with it (including
  28. ; this source file) and you don't try to make money from it either by selling
  29. ; it directly or incorporating it into a product you sell.
  30. ;
  31. ; Values for exit status:
  32. ;
  33. ;    0    - success
  34. ;    1    - could not install program
  35. ;    2    - no BIOS support present
  36. ;    3    - unsupported DOS version (< 3.0)
  37. ;    4    - invalid parameter
  38. ;
  39. ; Constants
  40. ; ---------
  41. ;
  42.     CR    = 0DH            ; Carriage return
  43.     LF    = 0AH            ; Linefeed
  44.     TAB    = 09H            ; Tab
  45. ;
  46.     ID    = 0DCH            ; Multiplex ID
  47. ;
  48.     CSEG    SEGMENT BYTE PUBLIC 'CODE'
  49. ;
  50.     $BEGIN    EQU    $
  51. ;
  52.     ORG    0100H
  53. ;
  54.     ASSUME    CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
  55. ;
  56.     SUBTTL    Data areas
  57.     PAGE+
  58. ;
  59. ; The following jump to the initialisation code also provides three bytes
  60. ; of storage, two of which are used later by the resident part of the code.
  61. ;
  62. BEGIN:    JMP    INIT            ; jump to initialisation code
  63. ;
  64. ; Redefine storage for the above jump
  65. ;
  66.     ORG    BEGIN
  67. MBIT    EQU    THIS BYTE        ; Make/Break bit
  68.     ORG    BEGIN+1
  69. ONOFF    EQU    THIS BYTE        ; On/Off flag (0=off, initially on)
  70. ;
  71. ; Back to normal storage allocation
  72. ;
  73.     ORG    BEGIN+3
  74. ;
  75. ; The following three values may be changed if required. MPID is the multiplex
  76. ; ID, and will only need alteration if some other TSR is using the same value.
  77. ; Choose another at random until it works! NEWKEY is the scan code value for
  78. ; the key to replace NUM LOCK. MODE is used to force a particular operation
  79. ; mode; it is particularly useful when a BIOS says that it supports the
  80. ; keyboard intercept function, but doesn't.
  81. ;
  82. MPID    DB    09FH            ; 102H Multiplex ID ** DO NOT MOVE **
  83. NEWKEY    DB    03BH            ; 103H Replacement key ** DO NOT MOVE **
  84. MODE    DB    0            ; 104H Mode selector ** DO NOT MOVE **
  85.                     ;    00H = auto
  86.                     ;    01H = use INT 15H
  87.                     ;    02H = use INT 09H
  88. ;
  89. INTOFF    DW    ?            ; Old interrupt vector offset
  90. INTSEG    DW    ?            ; Old interrupt vector segment
  91. I2FOFF    DW    ?            ; Old INT 2FH offset
  92. I2FSEG    DW    ?            ; Old INT 2FH segment
  93. ;
  94.     SUBTTL    INT 2FH (multiplex) handler
  95.     PAGE+
  96. ;
  97. ; This INT 2FH handler is hooked into the MS-DOS multiplex interrupt.
  98. ;
  99. ;    Input parameters:
  100. ;
  101. ;        AH    = handler ID (MPID for this program)
  102. ;              Calls with unrecognised handler IDs are passed on
  103. ;        AL    = function code
  104. ;                00    - get installation status
  105. ;                01    - get GOLD status
  106. ;                02    - set GOLD status
  107. ;
  108. ;    Output parameters:
  109. ;
  110. ;        AL    = result
  111. ;                Get installation status:
  112. ;                    FFH    - Already installed
  113. ;                Get GOLD status:
  114. ;                    00H    - OFF
  115. ;                    01H    - ON
  116. ;                Set GOLD status:
  117. ;                    00H    - OK
  118. ;
  119. I2FHAN    PROC    FAR
  120. ;
  121.     ASSUME    CS:CSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
  122. ;
  123.     CMP    AH,MPID            ; for this program?
  124.     JE    I2FH10            ; j if so
  125.     JMP    DWORD PTR I2FOFF    ; else use old handler
  126. ;
  127. I2FH10:    OR    AL,AL            ; AL=0, get installation status?
  128.     JNE    I2FH20            ; j if not
  129.     MOV    AL,0FFH            ; indicate already installed
  130.     IRET                ; and return
  131. ;
  132. I2FH20:    DEC    AL            ; AL=1, get GOLD status?
  133.     JNE    I2FH30            ; j if not
  134.     MOV    AL,ONOFF        ; get value
  135.     IRET                ; and return
  136. ;
  137. I2FH30:    DEC    AL            ; AL=2, set GOLD status?
  138.     JNE    I2FH40            ; j if not
  139.     MOV    ONOFF,DL        ; set new value, drop through
  140. ;
  141. I2FH40:    IRET                ; and return
  142. ;
  143. I2FHAN    ENDP
  144. ;
  145.     SUBTTL    INT 15H (system services) handler
  146.     PAGE+
  147. ;
  148. ; This INT 15H handler is hooked into the BIOS system services interrupt.
  149. ; It is used only if the keyboard interrupt intercept capability is available
  150. ; in the BIOS.
  151. ;
  152. ;    Input parameters:
  153. ;        AH    - function. Only 4FH (keyboard intercept) is handled;
  154. ;              other values cause the action to be passed to the
  155. ;              previous handler.
  156. ;        AL    - scan code for key just pressed
  157. ;
  158. ;    Output parameters:
  159. ;        AL    - input scan code, or mapped version of it.
  160. ;        CY    - set to indicate that keystroke is to be processed.
  161. ;        All other register contents are preserved.
  162. ;
  163.     ASSUME    CS:CSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
  164. ;
  165. I15HAN    PROC    FAR
  166. ;
  167.     CMP    AH,4FH            ; keyboard intercept function?
  168.     JE    I15H10            ; j if so
  169.     JMP    DWORD PTR INTOFF    ; else call old handler
  170. ;
  171. I15H10:    PUSH    AX            ; save register
  172.     MOV    AH,AL            ; copy scan code
  173.     AND    AH,80H            ; isolate make/break bit
  174.     MOV    MBIT,AH            ; save it
  175.     AND    AL,7FH            ; mask out make/break bit
  176.     CMP    AL,45H            ; NUM LOCK?
  177.     JNE    I15H60            ; j if not - just return
  178. ;
  179. ; NUM LOCK has been pressed. Check for SHIFT (retain normal action).
  180. ;
  181.     PUSH    DS            ; save segment
  182.     MOV    AX,40H            ; BIOS data segment
  183.     MOV    DS,AX            ; address BIOS data segment
  184.     MOV    AL,DS:[17H]        ; get keyboard flags
  185.     POP    DS            ; recover segment
  186.     AND    AL,0FH            ; mask out lock status
  187.     MOV    AH,AL            ; take copy for later comparison
  188.     CMP    ONOFF,0            ; is GOLD on?
  189.     JE    I15H20            ; j if not - do nothing here
  190.     AND    AL,03H            ; mask out ALT and CTRL status
  191.     JE    I15H20            ; j if not shifted
  192.     CMP    AH,AL            ; see if just SHIFT
  193.     JE    I15H60            ; if so, treat as normal NUM LOCK call
  194. ;
  195. ; Check for ALT (invert GOLD status). This needs to work whether GOLD is
  196. ; ON or OFF.
  197. ;
  198. I15H20:    MOV    AL,AH            ; recover shift status bits
  199.     AND    AL,08H            ; mask out CTRL and SHIFT status
  200.     JE    I15H40            ; j if not ALT - pass through
  201.     CMP    AH,AL            ; see if just ALT
  202.     JNE    I15H40            ; j if not - pass through
  203.     TEST    MBIT,80H        ; make operation?
  204.     JNE    I15H30            ; j if not - ignore
  205.     XOR    ONOFF,1            ; flip GOLD ON/OFF flag
  206. ;
  207. I15H30:    CLC                ; absorb keystroke
  208.     POP    AX            ; recover register
  209.     RETF    2            ; return, preserving flags
  210. ;
  211. I15H40:    CMP    ONOFF,0            ; is GOLD on?
  212.     JE    I15H60            ; j if not - do nothing
  213. ;
  214. I15H50:    POP    AX            ; recover register
  215.     MOV    AL,NEWKEY        ; set replacement scan code
  216.     OR    AL,MBIT            ; include make/break bit, drop through
  217.     STC                ; make sure keystroke processed
  218.     RETF    2            ; return, preserving flags
  219. ;
  220. I15H60:    STC                ; make sure keystroke processed
  221.     POP    AX            ; recover register
  222.     RETF    2            ; return, preserving flags
  223. ;
  224. I15HAN    ENDP
  225. ;
  226. I15LEN    =    $ - I15HAN        ; length of INT 15H handler
  227. ;
  228.     SUBTTL    INT 09H (keyboard interrupt) handler
  229.     PAGE+
  230. ;
  231. ; This INT 09H handler is hooked into the keyboard interrupt vector.
  232. ; It is used only if the keyboard interrupt intercept facility is not
  233. ; available in the BIOS, and is moved in memory so that the space occupied
  234. ; by the INT 15H handler is not wasted.
  235. ;
  236. ;    Input parameters:
  237. ;        No explicit inputs. Implicit input from the keyboard
  238. ;        hardware.
  239. ;
  240. ;    Output parameters:
  241. ;        No explicit outputs. Control is passed to the normal keyboard
  242. ;        interrupt handler unless the keystroke is to be modified or
  243. ;        absorbed. Modified keystrokes are placed into the BIOS input
  244. ;        buffer.
  245. ;        All registers are preserved.
  246. ;
  247. I09HAN    PROC    FAR
  248. ;
  249.     PUSH    AX            ; save register
  250.     IN    AL,60H            ; get next character from hardware
  251.     MOV    AH,AL            ; copy scan code
  252.     AND    AH,80H            ; isolate make/break bit
  253.     MOV    MBIT,AH            ; save it
  254.     AND    AL,7FH            ; mask out make/break bit
  255.     CMP    AL,45H            ; NUM LOCK?
  256.     JE    I09H10            ; j if so
  257.     JMP    I09H80            ; else just pass on to original handler
  258. ;
  259. ; NUM LOCK has been pressed. Check for SHIFT (retain normal action).
  260. ;
  261. I09H10:    PUSH    DS            ; save segment
  262.     MOV    AX,40H            ; BIOS data segment
  263.     MOV    DS,AX            ; address BIOS data segment
  264.     MOV    AL,DS:[17H]        ; get keyboard flags
  265.     POP    DS            ; recover segment
  266.     AND    AL,0FH            ; mask out lock status
  267.     MOV    AH,AL            ; take copy for later comparison
  268.     CMP    ONOFF,0            ; is GOLD on?
  269.     JE    I09H20            ; j if not - do nothing here
  270.     AND    AL,03H            ; mask out ALT and CTRL status
  271.     JE    I09H20            ; j if not shifted
  272.     CMP    AH,AL            ; see if just SHIFT
  273.     JE    I09H80            ; if so, treat as normal NUM LOCK call
  274. ;
  275. ; Check for ALT (invert GOLD status). This needs to work whether GOLD is
  276. ; ON or OFF.
  277. ;
  278. I09H20:    MOV    AL,AH            ; recover shift status bits
  279.     AND    AL,08H            ; mask out CTRL and SHIFT status
  280.     JE    I09H30            ; j if not ALT - pass through
  281.     CMP    AH,AL            ; see if just ALT
  282.     JNE    I09H30            ; j if not - pass through
  283.     TEST    MBIT,80H        ; make operation?
  284.     JNE    I09H70            ; j if not - ignore
  285.     XOR    ONOFF,1            ; flip GOLD ON/OFF flag
  286.     JMP    SHORT I09H70        ; absorb keystroke and exit
  287. ;
  288. I09H30:    CMP    ONOFF,0            ; is GOLD on?
  289.     JE    I09H80            ; j if not - pass through
  290. ;
  291. I09H40:    TEST    MBIT,80H        ; break code?
  292.     JNZ    I09H70            ; j if so - ignore
  293.     PUSH    DS            ; save segment
  294.     PUSH    SI            ; save register
  295.     PUSH    BX            ; save register
  296.     MOV    AX,40H            ; BIOS data segment
  297.     MOV    DS,AX            ; address it
  298.     MOV    BX,DS:[1CH]        ; get offset of next slot in buffer
  299.     MOV    SI,BX            ; save for later
  300.     ADD    BX,2            ; advance pointer
  301.     CMP    BX,DS:[82H]        ; time to wrap?
  302.     JNZ    I09H50            ; j if not
  303.     MOV    BX,DS:[80H]        ; else do it
  304. ;
  305. I09H50:    CMP    BX,DS:[1AH]        ; buffer is full?
  306.     JZ    I09H60            ; j if so - discard character
  307.     MOV    AH,NEWKEY        ; set replacement scan code
  308.     XOR    AL,AL            ; extended code
  309.     MOV    WORD PTR [SI],AX    ; set into buffer
  310.     MOV    DS:[1CH],BX        ; save updated buffer pointer
  311. ;
  312. I09H60:    POP    BX            ; recover register
  313.     POP    SI            ; recover register
  314.     POP    DS            ; recover segment
  315. ;
  316. ; Clear the keyboard port, acknowledging the character.
  317. ;
  318. I09H70:    IN    AL,61H            ; get control port
  319.     MOV    AH,AL            ; copy for later reset
  320.     OR    AL,80H            ; set bit to acknowledge
  321.     JMP    SHORT $+2        ; wait for settle
  322.     OUT    61H,AL            ; do the acknowledge
  323.     JMP    SHORT $+2        ; wait for settle
  324.     MOV    AL,AH            ; get original setting
  325.     OUT    61H,AL            ; put it back
  326.     JMP    SHORT $+2        ; wait for settle
  327.     MOV    AL,20H            ; End-Of-Interrupt
  328.     OUT    20H,AL            ; send to interrupt controller
  329.     POP    AX            ; recover register
  330.     IRET                ; return without calling original
  331. ;
  332. I09H80:    POP    AX            ; recover register
  333.     JMP    DWORD PTR INTOFF    ; jump to original interrupt handler
  334. ;
  335. I09HAN    ENDP
  336. ;
  337. I09LEN    =    $ - I09HAN        ; length of INT 09H handler
  338. ;
  339.     SUBTTL    Initialisation code
  340.     PAGE+
  341. ;
  342. ; This is the program initialisation code. It is not present in the resident
  343. ; copy of the program.
  344. ;
  345.     ASSUME    CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
  346. ;
  347. INIT:    MOV    ONOFF,1            ; set initial value
  348. ;
  349. ; Select the operating mode
  350. ;
  351.     CMP    MODE,2            ; force INT 09H to be used?
  352.     JE    INIT50            ; j if so
  353.     PUSH    ES            ; save ES
  354.     MOV    AH,0C0H            ; see if keyboard intercept supported
  355.     INT    15H            ; get system configuration parameters
  356.     JNC    INIT10            ; j if configuration call supported
  357.     POP    ES            ; recover ES
  358.     JMP    SHORT INIT20        ; try for INT 09H mode
  359. ;
  360. INIT10:    TEST    BYTE PTR ES:[BX+5],10H    ; see if intercept flag set
  361.     POP    ES            ; recover ES
  362.     JNE    INIT30            ; j if intercept supported - use it
  363. ;
  364. INIT20:    CMP    MODE,1            ; force INT 15H mode?
  365.     JNE    INIT40            ; j if not - use INT 09H mode
  366.     LEA    DX,MES0            ; 'Sorry - this machine does not...'
  367.     MOV    AH,9            ; output message
  368.     INT    21H            ; do it
  369.     MOV    AX,4C02H        ; exit with error status
  370.     INT    21H
  371. ;
  372. INIT30:    MOV    MODE,1            ; select INT 15H mode
  373.     JMP    SHORT INIT50        ; check DOS version now
  374. ;
  375. INIT40:    MOV    MODE,2            ; select INT 09H mode
  376. ;
  377. ; The INT 2FH code will work only on DOS 3.0 and above. See if it is OK
  378. ; to use it.
  379. ;
  380. INIT50:    MOV    AX,3000H        ; get DOS version
  381.     INT    21H            ; returns minor in AH, major in AL
  382.     CMP    AL,3            ; see if 3 or greater
  383.     JGE    INIT60            ; j if so - OK
  384.     LEA    DX,MES1            ; 'Sorry - DOS 3.0 or above is...'
  385.     MOV    AH,9            ; output message
  386.     INT    21H            ; do it
  387.     MOV    AX,4C03H        ; exit with error status
  388.     INT    21H
  389. ;
  390. ; See if already installed
  391. ;
  392. INIT60:    MOV    AH,MPID            ; multiplex ID
  393.     XOR    AL,AL            ; function 00H
  394.     XOR    BX,BX            ; zero for safety
  395.     XOR    CX,CX            ; zero for safety
  396.     XOR    DX,DX            ; zero for safety
  397.     INT    2FH            ; call multiplex
  398.     PUSH    CS            ; restore DS in case corrupted...
  399.     POP    DS            ; ...by other program
  400.     PUSH    CS            ; restore ES...
  401.     POP    ES            ; ...for same reason
  402.     OR    AL,AL            ; see if OK to install (AL unchanged)
  403.     JZ    INIT70            ; j if so
  404.     CMP    AL,0FFH            ; already installed?
  405.     JE    INIT100            ; j if so - skip installation
  406.     LEA    DX,MES2            ; 'Cannot install program'
  407.     MOV    AH,9            ; output message
  408.     INT    21H            ; do it
  409.     MOV    AX,4C01H        ; exit with error status
  410.     INT    21H
  411. ;
  412. ; Program is not installed; install it now.
  413. ;
  414. INIT70:    PUSH    ES            ; save segment
  415.     MOV    AX,352FH        ; get old INT 2FH handler
  416.     INT    21H            ; returns value in ES:BX
  417.     MOV    I2FOFF,BX        ; save offset
  418.     MOV    I2FSEG,ES        ; save segment
  419.     LEA    DX,I2FHAN        ; point to new INT 2FH handler
  420.     MOV    AX,252FH        ; set INT 2FH vector
  421.     INT    21H            ; from DS:DX
  422. ;
  423. ; Perform installation conditional on the selected mode
  424. ;
  425.     CMP    MODE,1            ; use INT 15H mode?
  426.     JNE    INIT80            ; j if not - set up for INT 09H
  427. ;
  428. ; Use the INT 15H code, which uses the BIOS keyboard interrupt intercept
  429. ;
  430.     MOV    AX,3515H        ; get old INT 15H handler
  431.     INT    21H            ; returns value in ES:BX
  432.     MOV    INTOFF,BX        ; save offset
  433.     MOV    INTSEG,ES        ; save segment
  434.     LEA    DX,I15HAN        ; point to new INT 15H handler
  435.     MOV    AX,2515H        ; set INT 15H vector
  436.     INT    21H            ; from DS:DX
  437.     POP    ES            ; recover segment
  438.     MOV    WORD PTR INTLEN,I15LEN    ; save interrupt routine length
  439.     JMP    SHORT INIT90        ; rejoin common code
  440. ;
  441. ; Use the INT 09H code, which uses the keyboard hardware interrupt
  442. ;
  443. INIT80:    MOV    AX,3509H        ; get old INT 09H handler
  444.     INT    21H            ; returns value in ES:BX
  445.     MOV    INTOFF,BX        ; save offset
  446.     MOV    INTSEG,ES        ; save segment
  447.     LEA    DX,I15HAN        ; point to new INT 09H handler
  448.                     ; (where it WILL be)
  449.     MOV    AX,2509H        ; set INT 09H vector
  450.     INT    21H            ; from DS:DX
  451.     POP    ES            ; recover segment
  452.     MOV    CX,I09LEN        ; get interrupt routine length
  453.     MOV    INTLEN,CX        ; save it
  454.     CLD                ; autoincrement
  455.     MOV    SI,OFFSET I09HAN    ; get address of interrupt routine
  456.     MOV    DI,OFFSET I15HAN    ; where to move it
  457.     REP    MOVSB            ; do so
  458. ;
  459. ; Complete installation
  460. ;
  461. INIT90:    INC    BYTE PTR RESFLAG    ; remember to stay resident
  462. ;
  463. ; The program is now installed. Handle parameters.
  464. ;
  465. INIT100:CLD                ; autoincrement
  466.     MOV    SI,81H            ; offset of command tail
  467.     MOV    DI,81H            ; put characters back in same place
  468. ;
  469. INIT110:LODSB                ; get next command character
  470.     CMP    AL,CR            ; end of command?
  471.     JE    INIT130            ; j if so
  472.     CMP    AL,'a'            ; check if lower case alphabetic
  473.     JL    INIT120            ; j if not
  474.     CMP    AL,'z'            ; check range
  475.     JG    INIT120            ; j if not in range
  476.     SUB    AL,'a'-'A'        ; convert to upper case
  477. ;
  478. INIT120:STOSB                ; return possibly modified character
  479.     JMP    INIT110            ; keep scanning
  480. ;
  481. INIT130:MOV    SI,81H            ; back to start of command tail
  482. ;
  483. INIT140:LODSB                ; get next character
  484.     CMP    AL,' '            ; space?
  485.     JE    INIT140            ; j if so - ignore
  486.     CMP    AL,TAB            ; tab?
  487.     JE    INIT140            ; j if so - ignore
  488.     CMP    AL,CR            ; end of parameters?
  489.     JE    INIT150            ; j if so
  490.     DEC    SI            ; point back to first non-space
  491.     MOV    BX,SI            ; save pointer
  492.     MOV    CX,2            ; check for ON
  493.     LEA    DI,ON            ; 'ON'
  494.     REP    CMPSB            ; matched?
  495.     JE    INIT190            ; j if so
  496.     MOV    SI,BX            ; recover pointer
  497.     MOV    CX,3            ; check for OFF
  498.     LEA    DI,OFF            ; 'OFF'
  499.     REP    CMPSB            ; matched?
  500.     JE    INIT180            ; j if so
  501.     LEA    DX,MES4            ; 'Parameter must be ON or OFF'
  502.     MOV    AH,9            ; output message
  503.     INT    21H            ; do it
  504.     MOV    AX,4C01H        ; indicate error
  505.     INT    21H            ; and exit
  506. ;
  507. ; No parameter given - just report status unless initial installation
  508. ;
  509. INIT150:LEA    DX,MES3            ; 'GOLD is '
  510.     MOV    AH,9            ; output message
  511.     INT    21H            ; do it
  512.     MOV    AH,MPID            ; multiplex ID
  513.     MOV    AL,1            ; request status
  514.     INT    2FH            ; returns AL=0 for OFF, AL=1 for ON
  515.     OR    AL,AL            ; test value
  516.     JNZ    INIT160            ; j if ON
  517.     LEA    DX,OFF            ; 'OFF'
  518.     JMP    SHORT INIT170        ; join common code
  519. ;
  520. INIT160:LEA    DX,ON            ; 'ON'
  521. ;
  522. INIT170:MOV    AH,9            ; output message
  523.     INT    21H            ; do it
  524.     JMP    SHORT INIT220        ; use common code
  525. ;
  526. INIT180:XOR    DL,DL            ; clear flag
  527.     JMP    SHORT INIT200        ; jump to setting code
  528. ;
  529. INIT190:MOV    DL,1            ; set flag
  530. ;
  531. ; AL now contains the required GOLD setting flag. Check that the rest of
  532. ; the command line is blank, then if all is OK set the flag appropriately.
  533. ;
  534. INIT200:LODSB                ; get next character
  535.     CMP    AL,' '            ; space?
  536.     JE    INIT200            ; j if so - ignore
  537.     CMP    AL,TAB            ; tab?
  538.     JE    INIT200            ; j if so - ignore
  539.     CMP    AL,CR            ; end of parameters?
  540.     JE    INIT210            ; j if so
  541.     LEA    DX,MES5            ; 'Invalid parameter'
  542.     MOV    AH,9            ; output message
  543.     INT    21H            ; do it
  544.     MOV    AX,4C04H        ; indicate error
  545.     INT    21H            ; and exit
  546. ;
  547. ; The command line is OK. Set the GOLD flag.
  548. ;
  549. INIT210:MOV    AH,MPID            ; multiplex ID
  550.     MOV    AL,2            ; set flag from DL
  551.     INT    2FH            ; set new flag value in resident copy
  552. ;
  553. ; If this is not the first load of GOLD, just exit.
  554. ;
  555. INIT220:TEST    BYTE PTR RESFLAG,1    ; make resident?
  556.     JNE    INIT230            ; j if so
  557.     MOV    AX,4C00H        ; else just exit with success
  558.     INT    21H
  559. ;
  560. ; This is the first load of GOLD; terminate and stay resident
  561. ;
  562. INIT230:MOV    ES,ES:[2CH]        ; get environment segment
  563.     MOV    AH,49H            ; free memory for it
  564.     INT    21H            ; do it
  565.     MOV    DX,OFFSET I15HAN    ; size of common part
  566.     ADD    DX,INTLEN        ; add size of interrupt routine
  567.     ADD    DX,15            ; round to next paragraph
  568.     MOV    CL,4            ; amount to shift
  569.     SHR    DX,CL            ; convert to paragraphs
  570.     MOV    AX,3100H        ; exit with success status
  571.     INT    21H            ; and stay resident
  572. ;
  573. INTLEN    DW    ?            ; Size of selected interrupt handler
  574. RESFLAG    DB    0            ; Set to 1 if to stay resident
  575. ;
  576. ON    DB    'ON',CR,LF,'$'
  577. OFF    DB    'OFF',CR,LF,'$'
  578. MES0    DB    'Sorry - this machine does not support the GOLD utility',CR,LF
  579.     DB    'if the interrupt intercept mode is selected'
  580.     DB    CR,LF,'$'
  581. MES1    DB    'Sorry - DOS 3.0 or above is required for the GOLD utility'
  582.     DB    CR,LF,'$'
  583. MES2    DB    'Sorry - cannot install the GOLD utility',CR,LF,'$'
  584. MES3    DB    'GOLD is $'
  585. MES4    DB    'Parameter must be ON or OFF',CR,LF,'$'
  586. MES5    DB    'Invalid parameter',CR,LF,'$'
  587. ;
  588. INFO    DB    '====GOLD version 2.2===='
  589. ;
  590. CSEG    ENDS
  591. ;
  592.     END    BEGIN
  593.